package com.ruoyi.zk.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zk.domain.ZkAdmitplan;
import com.ruoyi.zk.service.IZkAdmitplanService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 招生计划Controller
 * 
 * @author ruoyi
 * @date 2024-06-18
 */
@Controller
@RequestMapping("/zk/admitplan")
public class ZkAdmitplanController extends BaseController
{
    private String prefix = "zk/admitplan";

    @Autowired
    private IZkAdmitplanService zkAdmitplanService;

    @RequiresPermissions("zk:admitplan:view")
    @GetMapping()
    public String admitplan()
    {
        return prefix + "/admitplan";
    }

    /**
     * 查询招生计划列表
     */
    @RequiresPermissions("zk:admitplan:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZkAdmitplan zkAdmitplan)
    {
        startPage();
        List<ZkAdmitplan> list = zkAdmitplanService.selectZkAdmitplanList(zkAdmitplan);
        return getDataTable(list);
    }

    /**
     * 导出招生计划列表
     */
    @RequiresPermissions("zk:admitplan:export")
    @Log(title = "招生计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZkAdmitplan zkAdmitplan)
    {
        List<ZkAdmitplan> list = zkAdmitplanService.selectZkAdmitplanList(zkAdmitplan);
        ExcelUtil<ZkAdmitplan> util = new ExcelUtil<ZkAdmitplan>(ZkAdmitplan.class);
        return util.exportExcel(list, "招生计划数据");
    }

    /**
     * 新增招生计划
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存招生计划
     */
    @RequiresPermissions("zk:admitplan:add")
    @Log(title = "招生计划", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZkAdmitplan zkAdmitplan)
    {
        return toAjax(zkAdmitplanService.insertZkAdmitplan(zkAdmitplan));
    }

    /**
     * 修改招生计划
     */
    @RequiresPermissions("zk:admitplan:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZkAdmitplan zkAdmitplan = zkAdmitplanService.selectZkAdmitplanById(id);
        mmap.put("zkAdmitplan", zkAdmitplan);
        return prefix + "/edit";
    }

    /**
     * 修改保存招生计划
     */
    @RequiresPermissions("zk:admitplan:edit")
    @Log(title = "招生计划", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZkAdmitplan zkAdmitplan)
    {
        return toAjax(zkAdmitplanService.updateZkAdmitplan(zkAdmitplan));
    }

    /**
     * 删除招生计划
     */
    @RequiresPermissions("zk:admitplan:remove")
    @Log(title = "招生计划", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zkAdmitplanService.deleteZkAdmitplanByIds(ids));
    }
}
